package cn.xshi.sys.service.impl;
import java.util.List;
import java.util.Map;

import cn.xshi.sys.dao.SysUnitDao;
import cn.xshi.sys.model.SysUnit;
import cn.xshi.sys.service.SysUnitService;
import org.springframework.stereotype.Service;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import javax.annotation.Resource;
/**
 * @Desc 商品(产品)单位
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class SysUnitServiceImpl extends BaseService implements SysUnitService {

	@Resource
	private SysUnitDao sysUnitDao;

	/**
	* 分页
	* @param condition 
	* @return
	*/
	public List<SysUnit> getSysUnitListByCondition(Map<String,Object> condition){
		try {
			return sysUnitDao.getSysUnitListByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public SysUnit getSysUnitById(String id){
		try {
			return sysUnitDao.getSysUnitById(id);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param sysUnit
	* @return
	*/
	public int addSysUnit(SysUnit sysUnit){
		int i = 0;
		try {
			sysUnit.setId(toUUID());
			sysUnit.setCreateId(getCurrentAccountId());
			sysUnit.setCreateTime(getDate());
			i = sysUnitDao.addSysUnit(sysUnit);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param sysUnit
	* @return
	*/
	public int updateSysUnit(SysUnit sysUnit){
		int i = 0;
		try {
			sysUnit.setUpdateId(getCurrentAccountId());
			sysUnit.setUpdateTime(getDate());
			i = sysUnitDao.updateSysUnit(sysUnit);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delSysUnit(Map<String,Object> condition){
		int i = 0;
		try {
			i = sysUnitDao.delSysUnit(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
}
